#ifndef MODBUSSCANNER_H
#define MODBUSSCANNER_H
#include <QCoreApplication>
#include <QModbusRtuSerialMaster>
#include <QSerialPortInfo>
#include <QSerialPort>
#include <QTimer>
#include <QDebug>
#include <QQueue>
#include <QVariant>
class ModbusScanner : public QObject {
    Q_OBJECT
public:
    ModbusScanner(QObject *parent=nullptr);

    void startScan(int startAddr=1, int endAddr=127);

private slots:
    void onStateChanged(QModbusDevice::State state);

    void sendNextRequest();

private:
    QModbusRtuSerialMaster *modbusMaster;
    QQueue<int> addressQueue;
    QList<int> activeDevices;
};

#endif // MODBUSSCANNER_H
